Data

c =[cth(1) cth(2) cth(3) cth(4) w cth(1) cth(2) cth(3) cth(4) w cth(1) cth(2) cth(3) cth(4) w cth(1) cth(2) cth(3) cth(4) w cth(1) cth(2) cth(3) cth(4) w cth(1) cth(2) cth(3) cth(4) w cth(1) cth(2) cth(3) cth(4) w];
f1=[amoy1(1) amoy2(1) amoy3(1) amoy4(1) rau]./phinv(1);
f2=[amoy1(2) amoy2(2) amoy3(2) amoy4(2) rau]./phinv(2);
f3=[amoy1(3) amoy2(3) amoy3(3) amoy4(3) rau]./phinv(3);
f4=[amoy1(4) amoy2(4) amoy3(4) amoy4(4) rau]./phinv(4);
f5=[amoy1(5) amoy2(5) amoy3(5) amoy4(5) rau]./phinv(5);
f6=[amoy1(6) amoy2(6) amoy3(6) amoy4(6) rau]./phinv(6);
f7=[amoy1(7) amoy2(7) amoy3(7) amoy4(7) rau]./phinv(7);

b1 = [0 0 0 0 sigb(1)]';
b2 = [0 0 0 0 sigb(2)]';
b3 = [0 0 0 0 sigb(3)]';
b4 = [0 0 0 0 sigb(4)]';
b5 = [0 0 0 0 sigb(5)]';
b6 = [0 0 0 0 sigb(6)]';
b7 = [0 0 0 0 sigb(7)]';

A1=[siga1(1) 0 0 0; 0 siga2(1) 0 0; 0 0 siga3(1) 0; 0 0 0 siga4(1); 0 0 0 siga5(1)];
A2=[siga1(2) 0 0 0; 0 siga2(2) 0 0; 0 0 siga3(2) 0; 0 0 0 siga4(2); 0 0 0 siga5(2)];
A3=[siga1(3) 0 0 0; 0 siga2(3) 0 0; 0 0 siga3(3) 0; 0 0 0 siga4(3); 0 0 0 siga5(3)];
A4=[siga1(4) 0 0 0; 0 siga2(4) 0 0; 0 0 siga3(4) 0; 0 0 0 siga4(4); 0 0 0 siga5(4)];
A5=[siga1(5) 0 0 0; 0 siga2(5) 0 0; 0 0 siga3(5) 0; 0 0 0 siga4(5); 0 0 0 siga5(5)];
A6=[siga1(6) 0 0 0; 0 siga2(6) 0 0; 0 0 siga3(6) 0; 0 0 0 siga4(6); 0 0 0 siga5(6)];
A7=[siga1(7) 0 0 0; 0 siga2(7) 0 0; 0 0 siga3(7) 0; 0 0 0 siga4(7); 0 0 0 siga5(7)];

d1 = -bmoy(1)/phinv(1);
d2 = -bmoy(2)/phinv(2);
d3 = -bmoy(3)/phinv(3);
d4 = -bmoy(4)/phinv(4);
d5 = -bmoy(5)/phinv(5);
d6 = -bmoy(6)/phinv(6);
d7 = -bmoy(7)/phinv(7);

xmax = [ x1max(1) x2max(1) x3max(1) x4max(1) x5max(1) x1max(2) x2max(2) x3max(2) x4max(2) x5max(2) x1max(3) x2max(3) x3max(3) x4max(3) x5max(3) x1max(4) x2max(4) x3max(4) x4max(4) x5max(4) x1max(5) x2max(5) x3max(5) x4max(5) x5max(5) x1max(6) x2max(6) x3max(6) x4max(6) x5max(6) x1max(7) x2max(7) x3max(7) x4max(7) x5max(7)]';
mn=m*n;
debut = clock();
cvx_begin
	variable x(mn)
	minimize (c*x)
	subject to
	norm(A1*x(1:4)+b1,2) <= f1*x(1:n)+d1;
	norm(A2*x(6:9)+b2,2) <= f2*x(6:10)+d2;
	norm(A3*x(11:14)+b3,2) <= f3*x(11:15)+d3;
	norm(A4*x(16:19)+b4,2) <= f4*x(16:20)+d4;
	norm(A5*x(21:24)+b5,2) <= f5*x(21:25)+d5;
	norm(A6*x(26:29)+b6,2) <= f6*x(26:30)+d6;
	norm(A7*x(31:34)+b7,2) <= f7*x(31:35)+d7;
	x<=xmax;
	x(5) <= v0+ah(1) - vmin(1);
	x(5) >= v0+ah(1) - vmax(1);
	x(5) +  x(10) <= v0+(ah(1)+ah(2)) - vmin(2);
	x(5) +  x(10) >= v0+(ah(1)+ah(2)) - vmax(2);
	x(5) +  x(10) + x(15) <= v0+(ah(1)+ah(2)+ah(3)) - vmin(3);
	x(5) +  x(10) + x(15) >= v0+(ah(1)+ah(2)+ah(3)) - vmax(3);
	x(5) +  x(10) + x(15) + x(20) <= v0+(ah(1)+ah(2)+ah(3)+ah(4)) - vmin(4);
	x(5) +  x(10) + x(15) + x(20) >= v0+(ah(1)+ah(2)+ah(3)+ah(4)) - vmax(4);
	x(5) +  x(10) + x(15) + x(20) + x(25) <= v0+(ah(1)+ah(2)+ah(3)+ah(4)+ah(5)) - vmin(5);
	x(5) +  x(10) + x(15) + x(20) + x(25) >= v0+(ah(1)+ah(2)+ah(3)+ah(4)+ah(5)) - vmax(5);
	x(5) +  x(10) + x(15) + x(20) + x(25) + x(30) <= v0+(ah(1)+ah(2)+ah(3)+ah(4)+ah(5)+ah(6)) - vmin(6);
	x(5) +  x(10) + x(15) + x(20) + x(25) + x(30) >= v0+(ah(1)+ah(2)+ah(3)+ah(4)+ah(5)+ah(6)) - vmax(6);
	x(5) +  x(10) + x(15) + x(20) + x(25) + x(30) + x(35) <= v0+(ah(1)+ah(2)+ah(3)+ah(4)+ah(5)+ah(6)+ah(7)) - vmin(7);
	x(5) +  x(10) + x(15) + x(20) + x(25) + x(30) + x(35) >= v0+(ah(1)+ah(2)+ah(3)+ah(4)+ah(5)+ah(6)+ah(7)) - vmax(7);
	x>=0;
cvx_end

z=c*x-w*(ah(1)+ah(2)+ah(3)+ah(4)+ah(5)+ah(6)+ah(7));

fin = clock();
time = fin-debut;